<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--   获取绝对路径 -->
<c:set var="ctx" value="${pageContext.request.contextPath }" />
<%@ include file="/common/include/include.jsp"%>
</head>
<body>

	<div id="content-container">
		<%@ include file="/common/include/pageTitleBread.jsp"%>

		<div id="page-content">
			<div class="col-sm-12 eq-box-sm">
				<div class="panel lion-fullHeight">
					<div class="panel-body">
						<div class="bootstrap-table">
							<div class="fixed-table-toolbar">
								<div class="bars pull-left">
									<shiro:hasPermission name="admin:menu:save"> 
										<a id="add" class="btn btn-info data-toolbar"
											onclick="doPjax('${ctx }/admin/menu/save')"
											href="javascript:void(0);"><i class="demo-pli-add"></i> 添加</a>
									</shiro:hasPermission>
								</div>
							</div>
							<div class="fixed-table-container" style="padding-bottom: 0px;">
								<div class="fixed-table-body">
									<table id="treetable"
										class="demo-add-niftycheck table table-hover table-striped">
										<thead>
											<tr>
												<th style="width: 220px;"><div class="th-inner">机构名称</div></th>
												<th style="width: 50px;"><div class="th-inner">显示图标</div></th>
												<th style="width: 350px;"><div class="th-inner">地址</div></th>
												<th style="width: 100px;"><div class="th-inner">排序</div></th>
												<th style="width: 100px;"><div class="th-inner">是否显示</div></th>
												<th style="width: 200px;"><div class="th-inner">权限标识</div></th>
												<th style="width: 330px;"><div class="th-inner">操作</div></th>
											</tr>
										</thead>
										<tbody>
											<c:forEach var="m" items="${requestScope.menus }">
												<tr data-tt-id="F_${m.id }" >
															<td>
															  <span 
															  	<c:choose>
															  	  <c:when test="${m.childrens.size()>0 }">
															  		class="folder" 
															  	  </c:when>
															  	  <c:otherwise>
															  	    class="file" 
															  	  </c:otherwise>
															  	</c:choose>
															  >
															  	${m.name }
															  </span>
															</td>
												
															<td style="text-align: center;">
															  <a onclick="changeIcon('${m.id }')" href="javascript:void(0);">
															  	<c:choose>
															  	  <c:when test="${m.icon!=null }">
																	<i class="${m.icon }"></i>
																  </c:when>
																  <c:otherwise>
																	无
																  </c:otherwise>	
																</c:choose>
															  </a>
															</td>
															<td>${m.url }</td>
															<td>${m.sort }</td>
															<td>
															  <c:choose>
															  	<c:when test="${m.ifShow=='1' }">
															  		显示
															  	</c:when>
																<c:otherwise>
																	不显示
																</c:otherwise>
															  </c:choose>
															</td>
															<td>${m.permission }</td>
															<td>
																<shiro:hasPermission name="admin:menu:save"> 
																	<a class="label label-table label-info"
																		onclick="doPjax('${ctx }/admin/menu/save?parentid=${m.id }')"
																		href="javascript:void(0);">添加下级菜单
																	</a>&nbsp; 
																</shiro:hasPermission>
																
																<shiro:hasPermission name="admin:menu:update"> 	
																	<a class="label label-table label-success"
																		onclick="doPjax('${ctx }/admin/menu/update?id=${m.id }')"
																		href="javascript:void(0);">编辑
																	</a>&nbsp; 
																</shiro:hasPermission>
																
																<shiro:hasPermission name="admin:menu:delete"> 
																	<c:if test="${m.childrens.size()==0 }">
																		<a class="label label-table label-danger" onclick="del('${m.id }')"
																			href="javascript:void(0);">删除
																		</a>
																	</c:if>
																</shiro:hasPermission>
															</td>
														</tr>
												<c:if test="${m.childrens.size()>0 }">
													<c:forEach var="a" items="${m.childrens }">
														<tr data-tt-id="F_${a.id }"  data-tt-parent-id="F_${m.id }">
															<td>
															  <span 
															  	<c:choose>
															  	  <c:when test="${a.childrens.size()>0 }">
															  		class="folder" 
															  	  </c:when>
															  	  <c:otherwise>
															  	    class="file" 
															  	  </c:otherwise>
															  	</c:choose>
															  >
															  	${a.name }
															  </span>
															</td>
												
															<td style="text-align: center;">
															  <a onclick="changeIcon('${a.id }')" href="javascript:void(0);">
															  	<c:choose>
															  	  <c:when test="${a.icon!=null }">
																	<i class="${a.icon }"></i>
																  </c:when>
																  <c:otherwise>
																	无
																  </c:otherwise>	
																</c:choose>
															  </a>
															</td>
															<td>${a.url }</td>
															<td>${a.sort }</td>
															<td>
															  <c:choose>
															  	<c:when test="${a.ifShow=='1' }">
															  		显示
															  	</c:when>
																<c:otherwise>
																	不显示
																</c:otherwise>
															  </c:choose>
															</td>
															<td>${a.permission }</td>
															<td>
																<shiro:hasPermission name="admin:menu:save"> 
																	<a class="label label-table label-info"
																		onclick="doPjax('${ctx }/admin/menu/save?parentid=${a.id }')"
																		href="javascript:void(0);">添加下级菜单
																	</a>&nbsp; 
																</shiro:hasPermission>
																<shiro:hasPermission name="admin:menu:update"> 	
																	<a class="label label-table label-success"
																		onclick="doPjax('${ctx }/admin/menu/update?id=${a.id }')"
																		href="javascript:void(0);">编辑
																	</a>&nbsp; 
																</shiro:hasPermission>
																<shiro:hasPermission name="admin:menu:delete"> 
																	<c:if test="${a.childrens.size()==0 }">
																		<a class="label label-table label-danger" onclick="del('${a.id }')"
																			href="javascript:void(0);">删除
																		</a>
																	</c:if> 
																</shiro:hasPermission>
															</td>
														</tr>
														<c:if test="${a.childrens.size()>0 }">
															<c:forEach var="b" items="${a.childrens }">
																<tr data-tt-id="F_${b.id }" data-tt-parent-id="F_${a.id }">
																	<td>
																	  <span 
																	  	<c:choose>
																	  	  <c:when test="${b.childrens.size()>0 }">
																	  	
																	  		class="folder" 
																	  	  </c:when>
																	  	  <c:otherwise>
																	  	    class="file" 
																	  	  </c:otherwise>
																	  	</c:choose>
																	  >
																	  	${b.name }
																	  </span>
																	</td>
														
																	<td style="text-align: center;">
																	  <a onclick="changeIcon('${b.id }')" href="javascript:void(0);">
																	  	<c:choose>
																	  	  <c:when test="${b.icon!=null }">
																			<i class="${b.icon }"></i>
																		  </c:when>
																		  <c:otherwise>
																			无
																		  </c:otherwise>	
																		</c:choose>
																	  </a>
																	</td>
																	<td>${b.url }</td>
																	<td>${b.sort }</td>
																	<td>
																	  <c:choose>
																	  	<c:when test="${b.ifShow=='1' }">
																	  		显示
																	  	</c:when>
																		<c:otherwise>
																			不显示
																		</c:otherwise>
																	  </c:choose>
																	</td>
																	<td>${b.permission }</td>
																	<td>
																		<shiro:hasPermission name="admin:menu:save">
																			<a class="label label-table label-info"
																				onclick="doPjax('${ctx }/admin/menu/save?parentid=${b.id }')"
																				href="javascript:void(0);">添加下级菜单
																			</a>&nbsp; 
																		</shiro:hasPermission>
																		<shiro:hasPermission name="admin:menu:update">
																			<a class="label label-table label-success"
																				onclick="doPjax('${ctx }/admin/menu/update?id=${b.id }')"
																				href="javascript:void(0);">编辑
																			</a>&nbsp; 
																		</shiro:hasPermission>
																		<shiro:hasPermission name="admin:menu:delete">
																			<c:if test="${b.childrens.size()==0 }">
																				<a class="label label-table label-danger" onclick="del('${b.id }')"
																					href="javascript:void(0);">删除
																				</a>
																			</c:if>
																		</shiro:hasPermission>
																	</td>
																</tr>
																<c:if test="${b.childrens.size()>0 }">
																	<c:forEach var="c" items="${b.childrens }">
																		<tr data-tt-id="F_${c.id }" data-tt-parent-id="F_${b.id }">
																			<td>
																			  <span class="file">
																			  	${c.name }
																			  </span>
																			</td>
																
																			<td style="text-align: center;">
																			  <a onclick="changeIcon('${c.id }')" href="javascript:void(0);">
																			  	<c:choose>
																			  	  <c:when test="${c.icon!=null }">
																					<i class="${c.icon }"></i>
																				  </c:when>
																				  <c:otherwise>
																					无
																				  </c:otherwise>	
																				</c:choose>
																			  </a>
																			</td>
																			<td>${c.url }</td>
																			<td>${c.sort }</td>
																			<td>
																			  <c:choose>
																			  	<c:when test="${c.ifShow=='1' }">
																			  		显示
																			  	</c:when>
																				<c:otherwise>
																					不显示
																				</c:otherwise>
																			  </c:choose>
																			</td>
																			<td>${c.permission }</td>
																			<td>
																				<shiro:hasPermission name="admin:menu:update">	
																					<a class="label label-table label-success"
																						onclick="doPjax('${ctx }/admin/menu/update?id=${c.id }')"
																						href="javascript:void(0);">编辑
																					</a>&nbsp; 
																				</shiro:hasPermission>
																				<shiro:hasPermission name="admin:menu:delete">
																					<a class="label label-table label-danger" onclick="del('${c.id }')"
																					   href="javascript:void(0);">删除
																					</a>&nbsp; 
																				</shiro:hasPermission>
																			</td>
																		</tr>
																	</c:forEach>
																</c:if>
															</c:forEach>
														</c:if>
													</c:forEach>
												</c:if>
											</c:forEach>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script>
			$("#treetable").treetable({
				expandable : true
			});//树表格
			$('#treetable').treetable('expandAll');//展开所有
			
			//删除
			function del(id){
				pointLion.confimMsg("您是否要删除所选信息 ?<br/> 点击确认进行删除 , 点击取消取消该操作",null,function(){
					//执行删除
					var data = common_ajax.ajaxFunc("/admin/menu/delete",{id:id}, "json", null);
					//删除结果
					if(data.success){
						pointLion.alertMsg(data.message,"success",null,function(){
							doPjax(ctx+'/admin/menu/getListPage');//跳转到列表页
						});
					}else if(data==""){
						pointLion.alertMsg("您无删除该菜单的权限","danger",null,null);
					}else{
						pointLion.alertMsg(data.message,"danger",null,null);
					}
				});
			};

			//选择展示图标
			function changeIcon(id) {
				var index = layer.open({
					type : 2,
					title : false, //不显示标题栏
					area : [ '80%', '80%' ],
					shade : 0.8,
					id : 'changeIcon', //设定一个id，防止重复弹出
					resize : false,
					closeBtn : false,
					isOutAnim : false,
					btnAlign : 'c',
					content : ctx + '/admin/menu/getChangeIconPage?id=' + id
				});
			}
		</script>
	
		
</div>
</body>
</html>





<!-- #for(m:menu)
																	        		<tr data-tt-id="F_#(m.id)">
																					  <td><span class="folder">#(m.name)</span></td>
																					  <td>#(m.url)</td>
																					  <td>#(m.sort)</td>
																					  <td>#if(m.ifShow=='1') 显示  #else 不显示  #end</td>
																					  <td>#(m.permission)</td>
																					  <td>
																					  		<a class="label label-table label-info" onclick="doPjax('#(ctx)/admin/menu/getEditPage?parentid=#(m.id)')" href="javascript:void(0);" >添加下级菜单</a>&nbsp;
																							<a class="label label-table label-success" onclick="doPjax('#(ctx)/admin/menu/getEditPage?id=#(m.id)')" href="javascript:void(0);">编辑</a>&nbsp;
																							#if(!m.childrens)<a class="label label-table label-danger" onclick="del('#(m.id)')" href="javascript:void(0);" >删除</a>#end
																					  </td>
																					</tr>
																					#if(m.childrens)
																						#for(c:m.children)
																							<tr data-tt-id="F_#(c.id)" data-tt-parent-id="F_#(m.id)">
																							  <td><span class="file">#(c.name)</span></td>
																							  <td>#(c.url)</td>
																							  <td>#(c.sort)</td>
																							  <td>#if(c.ifShow=='1') 显示  #else 不显示  #end</td>
																							  <td>#(c.permission)</td>
																							  <td>
																							  		<a class="label label-table label-info" onclick="doPjax('#(ctx)/admin/menu/getEditPage?parentid=#(c.id)')" href="javascript:void(0);" >添加下级菜单</a>&nbsp;
																									<a class="label label-table label-success" onclick="doPjax('#(ctx)/admin/menu/getEditPage?id=#(c.id)')" href="javascript:void(0);">编辑</a>&nbsp;
																									<a class="label label-table label-danger" onclick="del('#(c.id)')" href="javascript:void(0);" >删除</a>
																							  </td>
																							</tr>																							
																						#end
																					#end
																	        	#end -->